package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysDictTypeDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysDictType;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysDictTypeDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    BasicColumn[] selectList = BasicColumn.columnList(dictTypeId, dictTypeName, isEnable, isCascade, memo);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysDictType> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysDictType> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysDictTypeResult")
    Optional<TSysDictType> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysDictTypeResult", value = {
        @Result(column="dict_type_id", property="dictTypeId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="dict_type_name", property="dictTypeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_enable", property="isEnable", jdbcType=JdbcType.BIT),
        @Result(column="is_cascade", property="isCascade", jdbcType=JdbcType.BIT),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysDictType> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysDictType, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysDictType, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int deleteByPrimaryKey(String dictTypeId_) {
        return delete(c -> 
            c.where(dictTypeId, isEqualTo(dictTypeId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int insert(TSysDictType record) {
        return MyBatis3Utils.insert(this::insert, record, TSysDictType, c ->
            c.map(dictTypeId).toProperty("dictTypeId")
            .map(dictTypeName).toProperty("dictTypeName")
            .map(isEnable).toProperty("isEnable")
            .map(isCascade).toProperty("isCascade")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int insertMultiple(Collection<TSysDictType> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysDictType, c ->
            c.map(dictTypeId).toProperty("dictTypeId")
            .map(dictTypeName).toProperty("dictTypeName")
            .map(isEnable).toProperty("isEnable")
            .map(isCascade).toProperty("isCascade")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int insertSelective(TSysDictType record) {
        return MyBatis3Utils.insert(this::insert, record, TSysDictType, c ->
            c.map(dictTypeId).toPropertyWhenPresent("dictTypeId", record::getDictTypeId)
            .map(dictTypeName).toPropertyWhenPresent("dictTypeName", record::getDictTypeName)
            .map(isEnable).toPropertyWhenPresent("isEnable", record::getIsEnable)
            .map(isCascade).toPropertyWhenPresent("isCascade", record::getIsCascade)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default Optional<TSysDictType> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysDictType, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default List<TSysDictType> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysDictType, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default List<TSysDictType> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysDictType, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default Optional<TSysDictType> selectByPrimaryKey(String dictTypeId_) {
        return selectOne(c ->
            c.where(dictTypeId, isEqualTo(dictTypeId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysDictType, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysDictType record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(dictTypeId).equalTo(record::getDictTypeId)
                .set(dictTypeName).equalTo(record::getDictTypeName)
                .set(isEnable).equalTo(record::getIsEnable)
                .set(isCascade).equalTo(record::getIsCascade)
                .set(memo).equalTo(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysDictType record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(dictTypeId).equalToWhenPresent(record::getDictTypeId)
                .set(dictTypeName).equalToWhenPresent(record::getDictTypeName)
                .set(isEnable).equalToWhenPresent(record::getIsEnable)
                .set(isCascade).equalToWhenPresent(record::getIsCascade)
                .set(memo).equalToWhenPresent(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int updateByPrimaryKey(TSysDictType record) {
        return update(c ->
            c.set(dictTypeName).equalTo(record::getDictTypeName)
            .set(isEnable).equalTo(record::getIsEnable)
            .set(isCascade).equalTo(record::getIsCascade)
            .set(memo).equalTo(record::getMemo)
            .where(dictTypeId, isEqualTo(record::getDictTypeId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_dict_type")
    default int updateByPrimaryKeySelective(TSysDictType record) {
        return update(c ->
            c.set(dictTypeName).equalToWhenPresent(record::getDictTypeName)
            .set(isEnable).equalToWhenPresent(record::getIsEnable)
            .set(isCascade).equalToWhenPresent(record::getIsCascade)
            .set(memo).equalToWhenPresent(record::getMemo)
            .where(dictTypeId, isEqualTo(record::getDictTypeId))
        );
    }
}